//
//  ActivityContentViewController.m
//  xpkc
//
//  Created by TopSage on 15/11/11.
//  Copyright (c) 2015年 TopSage. All rights reserved.
//

#import "ActivityContentViewController.h"
#import <WebKit/WebKit.h>
@interface ActivityContentViewController ()

@end

@implementation ActivityContentViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self creatView];
}
- (void)creatView{
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 100)];
    label.text = @"来自学派网www.studypay.com";
    label.textColor = [UIColor darkGrayColor];
    label.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:label];
    
    if (IsIOS8) {
        WKWebView *web = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.view.frame.size.height)];
        web.backgroundColor = CCOLOR;
        web.estimatedProgress;
        [web sizeToFit];
        [self.view addSubview:web];
        NSURLRequest *requeset = [NSURLRequest requestWithURL:[NSURL URLWithString:self.url]];
        [web loadRequest:requeset];
        
//        // 图片缩放的js代码
//        NSString *js = @"var count = document.images.length;for (var i = 0; i < count; i++) {var image = document.images[i];image.style.width=320;};window.alert('找到' + count + '张图');";
//        // 根据JS字符串初始化WKUserScript对象
//        WKUserScript *script = [[WKUserScript alloc] initWithSource:js injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
//        // 根据生成的WKUserScript对象，初始化WKWebViewConfiguration
//        WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
//        [config.userContentController addUserScript:script];
//        WKWebView *web = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:config];
//        [web loadHTMLString:@"<head></head><img src='http://www.nsu.edu.cn/v/2014v3/img/background/3.jpg' />"baseURL:nil];
//        [self.view addSubview:web];
    }else{
        UIWebView *web = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.view.frame.size.height)];
        web.backgroundColor = CCOLOR;
        web.delegate = self;
        [web setScalesPageToFit:YES];
        [self.view addSubview:web];
        NSURLRequest *requeset = [NSURLRequest requestWithURL:[NSURL URLWithString:self.url]];
        [web loadRequest:requeset];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
